//
// Created by Administrator on 2021/11/9.
//

#include <iostream>
#include <vector>

using namespace std;

class Solution {
public:
    int countBattleships(vector<vector<char>> &board) {
        unsigned int m = board.size(), n = board[0].size();
        int ans = 0;
        for (int i = 0; i < m; ++i) {
            for (int j = 0; j < n; ++j) {
                if (board[i][j] == 'X') {
                    if ((i == 0 || board[i - 1][j] == '.') && (j == 0 || board[i][j - 1] == '.'))
                        ++ans;
                }
            }
        }
        return ans;
    }
};

int main() {
    vector<vector<char>> board{{'X', '.', '.', 'X'},
                               {'.', '.', '.', 'X'},
                               {'.', '.', '.', 'X'}};
    Solution solution;
    cout << solution.countBattleships(board) << endl;
    return 0;
}